package com.trkj.controllers;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trkj.pojos.MedcineDetail;
import com.trkj.service.SSQueYaoService;

/**
 * 要哭缺药
 * @author Administrator
 *
 */
@Controller
public class SSQueShaoDrugs {
	@Autowired
	private SSQueYaoService ssQueYaoService;
	
	@GetMapping("/to_SSQueYao")
	public String SSQueYao() {
		return "SSQueYao";
	}
	/**
	 * 删除多条药库缺药详情
	 * @param SSLackDrugId
	 */
	@GetMapping("/deleteSSLackDrug")
	@ResponseBody
	public String deleteSSLackDrug(String SSLackDrugId) {
		ssQueYaoService.deleteSSLackDrug(SSLackDrugId);
		return "";
	}
	/**
	 * 获取所有的药库缺药详情
	 * @param page
	 * @param rows
	 * @return
	 */
	@GetMapping("/getAllSSQueYao_Map")
	@ResponseBody
	public Map getAllSSQueYao_Map(int page,int rows) {
		return ssQueYaoService.getAllSSQueYaoMap(page, rows);
	}
	/**
	 * 新增药库计划采购详情
	 * @return
	 */
	@GetMapping("/addNewSSBuyDrugDetail")
	@ResponseBody
	public String addNewSSBuyDrugDetail(String medcineName,String medcineNumber) {
//		System.out.println("medcineName="+medcineName);
//		System.out.println("medcineNumber="+medcineNumber);
		ssQueYaoService.addNewSSBuyDrugDetail(medcineName, medcineNumber);
		return "";
	}
	/**
	 * 获取所有的药品
	 * @return
	 */
	@GetMapping("/getAllMedcineDetailList")
	@ResponseBody
	public List<MedcineDetail> getAllMedcineDetailList(){
		return ssQueYaoService.getAllMedcineDetail();
	}
	/**
	 * 新增药库详情
	 * @param medcineId
	 * @param medcineNumber
	 * @param staffId
	 * @param note
	 */
	@PostMapping("/addNewSSLackDrugForm")
	public void addNewSSLackDrugForm(Long medcineId,BigDecimal medcineNumber,String staffId,String note) {
		ssQueYaoService.addNewSSLackDrug(medcineId, medcineNumber, staffId, note);
	}
	
	/**
	 * 按条件分页查询缺药相关详情
	 * @param medcineTypeId
	 * @param staffId
	 * @return
	 */
	@GetMapping("/getSSLackDrugBySome")
	@ResponseBody
	public Map getSSLackDrugBySome(int page,int rows,Long medcineTypeId,Long staffId) {
		Map map = new HashMap<>();
		map.put("medcineTypeId", medcineTypeId);
		map.put("staffId", staffId);
		return ssQueYaoService.querySomeSSLackDrug(page, rows, map);
	}
	/**
	 * 按药品详情查询单条药库缺药详情
	 * @param medcineName
	 * @return
	 */
	@GetMapping("/querySSLackDrugByDrugName")
	@ResponseBody
	public Map getSSLackDrugByMedcineName(int page,int rows,String medcineName) {
		Map map =new HashMap<>();
		map.put("medcineName", medcineName);
		return ssQueYaoService.QuerySSLackDrugByName(page, rows, map);
	}
	/**
	 * 获取到所有药库计划购药详情
	 * @param page
	 * @param rows
	 * @return
	 */
	@GetMapping("/getAllSSBuyDrugDetail")
	@ResponseBody
	public Map getAllSSBuyDrugDetail(int page,int rows) {
		return ssQueYaoService.QueryAllSSBuyDrugDetailMap(page, rows);
	}
}
